# Contributor: Raed Rizqie <raed.rizqie@gmail.com>

_realname=requests-unixsocket
pkgbase=mingw-w64-python-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-python-${_realname}
pkgver=0.3.0
pkgrel=3
pkgdesc='Use requests to talk HTTP via a UNIX domain socket (mingw-w64)'
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
url='https://github.com/msabramo/requests-unixsocket'
license=('spdx:Apache-2.0')
depends=(
    ${MINGW_PACKAGE_PREFIX}-python
    ${MINGW_PACKAGE_PREFIX}-python-requests
    ${MINGW_PACKAGE_PREFIX}-python-urllib3)
makedepends=(
    ${MINGW_PACKAGE_PREFIX}-python-pbr
    ${MINGW_PACKAGE_PREFIX}-python-setuptools
    ${MINGW_PACKAGE_PREFIX}-python-wheel)
source=("${_realname}-${pkgver}.tar.gz::https://pypi.org/packages/source/r/${_realname}/${_realname}-${pkgver}.tar.gz")
sha256sums=('28304283ea9357d45fff58ad5b11e47708cfbf5806817aa59b2a363228ee971e')

prepare() {
  rm -rf python-build-${MSYSTEM} | true
  cp -r "${_realname}-${pkgver}" "python-build-${MSYSTEM}"

  # Set version for setuptools_scm
  export SETUPTOOLS_SCM_PRETEND_VERSION=${pkgver}
  export PBR_VERSION=${pkgver}
}

build() {
  msg "Python build for ${MSYSTEM}"
  cd "${srcdir}/python-build-${MSYSTEM}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${MSYSTEM}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE"
}
